package com.pzl.classloader;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    private Bean bean;
    private ListView listView;

    private void initView() {
        listView = (ListView) findViewById(R.id.listview);
    }

    private void initData() {
        bean = new Bean();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initData();
        initView();
        listView.setAdapter(new MyBaseAdapter(this));
        //test02();
        //test01();
    }

    private void test01() {
        Class mainActivityClaz = this.getClass();//实例拿内存的Class对象
        ClassLoader classLoader = mainActivityClaz.getClassLoader();
        System.out.println(classLoader);
        System.out.println(classLoader.getParent());
        System.out.println(classLoader.getParent().getParent());
    }

    private void test02() throws ClassNotFoundException {
        Class beanClaz = bean.getClass();//实例拿内存的Class对象
        ClassLoader classLoader = beanClaz.getClassLoader();
        System.out.println(classLoader);
        classLoader.loadClass("Test");
        System.out.println("------------------------------------");
        Class.forName("Test");
        System.out.println("------------------------------------");
        Class.forName("Test", false, classLoader);
        System.out.println("------------------------------------");
    }
}
